package com.ease.actionscript.mapping.mapper;

import java.lang.reflect.Constructor;
import java.lang.reflect.Modifier;

import com.ease.model.NamespaceModel;

/**
 * 
 * @author nathanleewei
 * 
 */
public class ValueObjectClassMapper extends AbstractValueObjectClassMapper {

	public boolean isCompliant() {
		boolean compliant = true;

		if (!Modifier.isAbstract(clazz.getModifiers())) {
			// 检查 value object都需要有无参public构造函数
			Constructor<?> constructor = null;
			try {
				constructor = clazz.getConstructor();
			} catch (Exception e) {
			}
			if (null == constructor) {
				compliant = false;
				warn("no-argument constructor not found: " + clazz.getName());
			}
		}

		return compliant && super.isCompliant();
	}

	public void prepare() {
		super.prepare();

		if ("NamespaceModel".equals(clazz.getSimpleName())) {
			this.addImportClassName(NamespaceModel.class.getName());
		}

	}
}
